package tx.bjdacp.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bjdacp.model.*;
import tx.bjdacp.dao.*;
import tx.bjdacp.service.*;
import tx.bjdacp.vo.query.*;


@Entity
@Table(name = "bjdacp_sample_info")
public class SampleInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "抽样情况";
	public static final String ALIAS_SAMPLE_INFO_ID = "sampleInfoId";
	public static final String ALIAS_DRUG_SELL_UNIT_ID = "drugSellUnitId";
	public static final String ALIAS_SAMPLE_NUMBER = "抽样编号";
	public static final String ALIAS_SAMPLE_DATE = "抽样日期";
	public static final String ALIAS_SAMPLED_UNIT_NAME = "被抽样单位名称";
	public static final String ALIAS_UNIT_KIND = "企业性质";
	public static final String ALIAS_SAMPLE_UNIT = "检验单位";
	public static final String ALIAS_SAMPLE_PRODUCT = "抽验产品";
	public static final String ALIAS_PRODUCT_TYPE = "产品种类";
	public static final String ALIAS_AMOUNT = "数量";
	public static final String ALIAS_BATCH_NUMBER = "批号";
	public static final String ALIAS_SAMPLE_KIND = "抽样性质";
	public static final String ALIAS_REPORT_NUMBER = "报告编号";
	public static final String ALIAS_REPORT_DATE = "检验报告日期";
	public static final String ALIAS_REPORT_RESULT = "检验结果";
	public static final String ALIAS_RECEIVE_REPORT_DATE = "收到检验报告日期";
	public static final String ALIAS_SAMPLE_YEAR = "年度";

	//date formats
	public static final String FORMAT_SAMPLE_DATE = DATE_FORMAT;
	public static final String FORMAT_REPORT_DATE = DATE_FORMAT;
	public static final String FORMAT_RECEIVE_REPORT_DATE = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * sampleInfoId       db_column: sample_info_id
     */
	
	private java.lang.Integer sampleInfoId;
    /**
     * drugSellUnitId       db_column: drug_sell_unit_id
     */
	
	private java.lang.Integer drugSellUnitId;
    /**
     * 抽样编号       db_column: sample_number
     */
	@Length(max=100)
	private java.lang.String sampleNumber;
    /**
     * 抽样日期       db_column: sample_date
     */
	
	private java.util.Date sampleDate;
    /**
     * 被抽样单位名称       db_column: sampled_unit_name
     */
	@Length(max=100)
	private java.lang.String sampledUnitName;
    /**
     * 企业性质       db_column: unit_kind
     */
	@Length(max=100)
	private java.lang.String unitKind;
    /**
     * 检验单位       db_column: sample_unit
     */
	@Length(max=100)
	private java.lang.String sampleUnit;
    /**
     * 抽验产品       db_column: sample_product
     */
	@Length(max=100)
	private java.lang.String sampleProduct;
    /**
     * 产品种类       db_column: product_type
     */
	@Length(max=100)
	private java.lang.String productType;
    /**
     * 数量       db_column: amount
     */
	@Length(max=100)
	private java.lang.String amount;
    /**
     * 批号       db_column: batch_number
     */
	@Length(max=100)
	private java.lang.String batchNumber;
    /**
     * 抽样性质       db_column: sample_kind
     */
	@Length(max=100)
	private java.lang.String sampleKind;
    /**
     * 报告编号       db_column: report_number
     */
	@Length(max=100)
	private java.lang.String reportNumber;
    /**
     * 检验报告日期       db_column: report_date
     */
	
	private java.util.Date reportDate;
    /**
     * 检验结果       db_column: report_result
     */
	@Length(max=100)
	private java.lang.String reportResult;
    /**
     * 收到检验报告日期       db_column: receive_report_date
     */
	
	private java.util.Date receiveReportDate;
    /**
     * 年度       db_column: sample_year
     */
	@Length(max=10)
	private java.lang.String sampleYear;
	//columns END


	public SampleInfo(){
	}

	public SampleInfo(
		java.lang.Integer sampleInfoId
	){
		this.sampleInfoId = sampleInfoId;
	}



	public void setSampleInfoId(java.lang.Integer value) {
		this.sampleInfoId = value;
	}

	@Id	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "sample_info_id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getSampleInfoId() {
		return this.sampleInfoId;
	}

	@Column(name = "drug_sell_unit_id", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getDrugSellUnitId() {
		return this.drugSellUnitId;
	}

	public void setDrugSellUnitId(java.lang.Integer value) {
		this.drugSellUnitId = value;
	}

	@Column(name = "sample_number", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSampleNumber() {
		return this.sampleNumber;
	}

	public void setSampleNumber(java.lang.String value) {
		this.sampleNumber = value;
	}

	@Transient
	public String getSampleDateString() {
		return DateConvertUtils.format(getSampleDate(), FORMAT_SAMPLE_DATE);
	}
	public void setSampleDateString(String value) {
		setSampleDate(DateConvertUtils.parse(value, FORMAT_SAMPLE_DATE,java.util.Date.class));
	}

	@Column(name = "sample_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getSampleDate() {
		return this.sampleDate;
	}

	public void setSampleDate(java.util.Date value) {
		this.sampleDate = value;
	}

	@Column(name = "sampled_unit_name", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSampledUnitName() {
		return this.sampledUnitName;
	}

	public void setSampledUnitName(java.lang.String value) {
		this.sampledUnitName = value;
	}

	@Column(name = "unit_kind", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getUnitKind() {
		return this.unitKind;
	}

	public void setUnitKind(java.lang.String value) {
		this.unitKind = value;
	}

	@Column(name = "sample_unit", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSampleUnit() {
		return this.sampleUnit;
	}

	public void setSampleUnit(java.lang.String value) {
		this.sampleUnit = value;
	}

	@Column(name = "sample_product", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSampleProduct() {
		return this.sampleProduct;
	}

	public void setSampleProduct(java.lang.String value) {
		this.sampleProduct = value;
	}

	@Column(name = "product_type", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getProductType() {
		return this.productType;
	}

	public void setProductType(java.lang.String value) {
		this.productType = value;
	}

	@Column(name = "amount", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getAmount() {
		return this.amount;
	}

	public void setAmount(java.lang.String value) {
		this.amount = value;
	}

	@Column(name = "batch_number", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getBatchNumber() {
		return this.batchNumber;
	}

	public void setBatchNumber(java.lang.String value) {
		this.batchNumber = value;
	}

	@Column(name = "sample_kind", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSampleKind() {
		return this.sampleKind;
	}

	public void setSampleKind(java.lang.String value) {
		this.sampleKind = value;
	}

	@Column(name = "report_number", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getReportNumber() {
		return this.reportNumber;
	}

	public void setReportNumber(java.lang.String value) {
		this.reportNumber = value;
	}

	@Transient
	public String getReportDateString() {
		return DateConvertUtils.format(getReportDate(), FORMAT_REPORT_DATE);
	}
	public void setReportDateString(String value) {
		setReportDate(DateConvertUtils.parse(value, FORMAT_REPORT_DATE,java.util.Date.class));
	}

	@Column(name = "report_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getReportDate() {
		return this.reportDate;
	}

	public void setReportDate(java.util.Date value) {
		this.reportDate = value;
	}

	@Column(name = "report_result", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getReportResult() {
		return this.reportResult;
	}

	public void setReportResult(java.lang.String value) {
		this.reportResult = value;
	}

	@Transient
	public String getReceiveReportDateString() {
		return DateConvertUtils.format(getReceiveReportDate(), FORMAT_RECEIVE_REPORT_DATE);
	}
	public void setReceiveReportDateString(String value) {
		setReceiveReportDate(DateConvertUtils.parse(value, FORMAT_RECEIVE_REPORT_DATE,java.util.Date.class));
	}

	@Column(name = "receive_report_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getReceiveReportDate() {
		return this.receiveReportDate;
	}

	public void setReceiveReportDate(java.util.Date value) {
		this.receiveReportDate = value;
	}

	@Column(name = "sample_year", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.String getSampleYear() {
		return this.sampleYear;
	}

	public void setSampleYear(java.lang.String value) {
		this.sampleYear = value;
	}


	private DrugSellUnit drugSellUnit;
	public void setDrugSellUnit(DrugSellUnit drugSellUnit){
		this.drugSellUnit = drugSellUnit;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "drug_sell_unit_id",nullable = false, insertable = false, updatable = false) 
	})
	public DrugSellUnit getDrugSellUnit() {
		return drugSellUnit;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("SampleInfoId",getSampleInfoId())
			.append("DrugSellUnitId",getDrugSellUnitId())
			.append("SampleNumber",getSampleNumber())
			.append("SampleDate",getSampleDate())
			.append("SampledUnitName",getSampledUnitName())
			.append("UnitKind",getUnitKind())
			.append("SampleUnit",getSampleUnit())
			.append("SampleProduct",getSampleProduct())
			.append("ProductType",getProductType())
			.append("Amount",getAmount())
			.append("BatchNumber",getBatchNumber())
			.append("SampleKind",getSampleKind())
			.append("ReportNumber",getReportNumber())
			.append("ReportDate",getReportDate())
			.append("ReportResult",getReportResult())
			.append("ReceiveReportDate",getReceiveReportDate())
			.append("SampleYear",getSampleYear())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getSampleInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof SampleInfo == false) return false;
		if(this == obj) return true;
		SampleInfo other = (SampleInfo)obj;
		return new EqualsBuilder()
			.append(getSampleInfoId(),other.getSampleInfoId())
			.isEquals();
	}
}

